package com.infore.siteManagement.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class FileConfig implements WebMvcConfigurer {
 
	@Value("${fileRoot}")
	private String fileRoot; //配置文件配置的物理保存地址
	@Override
	/**
	 * 将物理地址转化成服务器地址，实现图片预览
	 */
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
       registry.addResourceHandler("/image/**").addResourceLocations("file:"+fileRoot);
       WebMvcConfigurer.super.addResourceHandlers(registry);
	}
	
}
